package com.hxzy.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author wzm
 * @create 2023-10-13 14:45
 * project_name:stu_sys
 */
@Component
public class LoginCheckInterceptor_old implements HandlerInterceptor {

    //目标方法执行前需要执行的方法
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("方法执行前运行");
        //返回true 表示执行方法前调用时直接放行  false 不放行 拦截住
        return false;
    }

    //调用方法后执行
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("controller方法执行后执行");
    }

    //当项目整合的视图渲染完毕后执行，最后执行
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("视图渲染完毕后执行");
    }
}
